package link.anyauto.fsmgr.biz.login;

import android.databinding.DataBindingUtil;
import android.text.TextUtils;

import link.anyauto.fsmgr.R;
import link.anyauto.fsmgr.base.ActBase;
import link.anyauto.fsmgr.base.BaseNames;
import link.anyauto.fsmgr.databinding.ActLoginBinding;
import link.anyauto.fsmgr.util.StorageUtil;

public class ActLogin extends ActBase {

    @Override
    protected void initBinding() {
        binding = DataBindingUtil.setContentView(this, R.layout.act_login);
    }

    protected void initVM() {
        vm = new LoginVM();
        vm.setAcount(StorageUtil.get(BaseNames.KEY_ACCOUNT));
    }

    protected void initHandlers() {
        handlers = new LoginHandlers();
        handlers.login = vm;
        handlers.context = this;
        handlers.accountE = binding.account;
        handlers.pwdE = binding.pwd;
    }

    @Override
    protected void postInit() {
        binding.setVm(vm);
        binding.setHandlers(handlers);
    }

    @Override
    protected void unbind() {
        binding.unbind();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        StorageUtil.save(BaseNames.KEY_ACCOUNT, vm.getAccount());
    }

    LoginVM vm;
    LoginHandlers handlers;
    ActLoginBinding binding;
}
